package com.tanhua.server.service;


import com.tanhua.dubbo.api.UserLocationApi;
import com.tanhua.model.vo.ErrorResult;
import com.tanhua.server.exception.BusinessException;
import com.tanhua.server.interceptor.UserHolder;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

@Service
public class BaiduService {
    @DubboReference
    private UserLocationApi userLocationApi;

    public void updateLocation(Double latitude, Double longitude, String addrStr) {
        Long userId = UserHolder.getUserId();
        //调用api
        Boolean aBoolean = userLocationApi.updateLocation(userId, longitude, latitude, addrStr);
        if(!aBoolean){
            //为false,抛出异常
            throw new BusinessException(ErrorResult.error());
        }
    }

}
